package com.digiproto.app_store;

import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.digiproto.app_store.adapter.GameDetailFragmentAdapter;
import com.digiproto.app_store.model.Game;
import com.digiproto.app_store.widget.NoScrollViewPager;
import com.gxz.PagerSlidingTabStrip;

public class GameDetailActivity extends AppCompatActivity {

    public PagerSlidingTabStrip psts_tabs;
    public NoScrollViewPager vp_content;
    public TextView tv_title;

    private GameDetailFragmentAdapter gameDetailFragmentAdapter;
    private ViewPager viewPager;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game_detail);

        // 获取传递过来的数据
        Bundle bundle = this.getIntent().getExtras();
        // 对应详情页的Game对象
        Game game = (Game) bundle.get("selectGame");

        psts_tabs = (PagerSlidingTabStrip) findViewById(R.id.psts_tabs);
        // 内容页
        vp_content = (NoScrollViewPager) findViewById(R.id.vp_content);
        // title
        tv_title = (TextView) findViewById(R.id.tv_title);
        // 详情页代理
        gameDetailFragmentAdapter = new GameDetailFragmentAdapter(getSupportFragmentManager(),game);
        // 设置页面代理
        vp_content.setAdapter(gameDetailFragmentAdapter);
        // 页面偏移限制
        vp_content.setOffscreenPageLimit(1);
        // 设置view页面
        psts_tabs.setViewPager(vp_content);
        // bindViews();
    }

    /**
     * dont konw
     */
    private void bindViews() {
        // viewPager = (ViewPager) findViewById(R.id.vpager);
        viewPager.setAdapter(gameDetailFragmentAdapter);
        viewPager.setCurrentItem(0);
    }
}
